import request from "@/utils/request";
import {BaseResponse} from "@/api/types/baseResponse";
import SalaryItemResponse from "@/api/types/salary/SalaryItemResponse";
import SalaryItemRequest from "@/api/types/salaryItem/SalaryItemRequest";

// 获取所有薪资项
export async function getSalaryItems() {
    return await request<
        BaseResponse<{ info_list?: SalaryItemResponse[] }>,
        BaseResponse<{ info_list?: SalaryItemResponse[] }>
    >({
        url: "/salary/salaryitem"
    })
}

// 增加薪资项
export async function addSalaryItem(name: string) {
    return await request<BaseResponse<{}>, BaseResponse<{}>>({
        url: "/salary/salaryitem",
        method: "POST",
        data: {salaryitem_name: name}
    })
}

// 修改薪资项
export async function updateSalaryItem(salaryItem: SalaryItemRequest) {
    return await request<BaseResponse<undefined>, BaseResponse<undefined>>({
        url: "/salary/salaryitem",
        method: "PUT",
        data: salaryItem
    })
}

// 根据ID删除薪资项
export async function deleteSalaryItemById(id: number) {
    return await request<BaseResponse<boolean>, BaseResponse<boolean>>({
        url: "/salary/salaryitem",
        method: "DELETE",
        data: {salaryitem_id: id}
    })
}
